package com.example.fluentmybatis.controller;

import com.example.fluentmybatis.common.R;
import com.example.fluentmybatis.dto.ScoreStatisticDTO;
import com.example.fluentmybatis.service.IStudentService;
import com.example.fluentmybatis.vo.StudentQueryParamVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : Mr Li
 * @description : 学生业务处理器
 * @since : 2021/8/6 2:55 下午
 */
@RestController
@RequestMapping("/studentController")
public class StudentController {

    @Autowired
    private IStudentService studentService;

    /**
     * 统计从fromYear到endYear年间学科subjects的统计数据
     *
     * @param vo 查询所需参数实体
     * @return 统计数据列
     */
    @GetMapping("/getStudentList")
    public R<List<ScoreStatisticDTO>> getStudentList(StudentQueryParamVO vo){
        List<ScoreStatisticDTO> statistics = studentService.statistics(vo.getFromYear(), vo.getEndYear(), vo.getSubjects());
        return R.ok(statistics);
    }
}
